<?php

class Test extends Controller {

	//function __construct()
        function Test()
        {
                parent::Controller();
                $this->load->model('test_model');
                $this->load->library('form_validation');
        }

        function Register()
	{
            	//Check if the Registration form was submitted

            $this->load->library('form_validation');

            if ($this->input->post('submit_user'))
            {
                //Validate & Prep
                $this->form_validation->set_rules('first_name', 'firstname field', 'trim|required|max_length[15]');
                $this->form_validation->set_rules('last_name', 'lastname field', 'trim|required|max_length[15]');
                $this->form_validation->set_rules('email', 'email field', 'trim|required|max_length[50]');
                $this->form_validation->set_rules('username', 'username field', 'trim|required|max_length[15]');
                $this->form_validation->set_rules('password', 'password field', 'trim|required|max_length[15]');
                        
                $result = $this->form_validation->run();

                if ($result == TRUE)
                {

                    echo "<p>You have successfully registered!</p>";

                }
                    else
                        {
                            echo "<p>It failed.</p>";
                            echo "There were errors with your registration";
                            echo "<p>" . validation_errors() . "</p>";
                        }
                }

                $this->load->view('test');
	}

        function Story()
        {

            if ($this->input->post('submit_story'))
            {
                //Validate & Prep
                $this->form_validation->set_rules('story', 'story field', 'required|max_length[200]');

                $results = $this->form_validation->run();

                if ($results == TRUE)
                {

                    echo "<p>Successfully added story.</p>";

                }
                    else
                        {
                            echo "<p>It failed.</p>";
                            echo "<p>" . validation_errors() . "</p>";
                        }
                }

                $this->load->view('user/story');
        }
        
}
?>